<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>ums</title>
    <script src="${pageContext.request.contextPath}/js/jquery-3.3.1.min.js"></script>

    <script>
        $(function(){
            $("#username").blur(function(){
                $.ajax({
                    url:"${pageContext.request.contextPath}/user/validateUsername",
                    data:{"username":$(this).val()},
                    type:"POST",
                    success:function(ajaxResult){
                        if("200"==ajaxResult.code){
                            $("#usernameMessage").css("color","green");
                        }else{
                            $("#usernameMessage").css("color","red");
                        }
                        $("#usernameMessage").text(ajaxResult.message);
                    }
                });
            });
        });
    </script>
</head>
<body>
    <h1>用户注册</h1>
    <hr/>
    <form action="${pageContext.request.contextPath}/user/regist" method="post">
    账号：<input type="text" id="username" name="username"/>
         <span id="usernameMessage"></span><br/>
    密码：<input type="password" name="password"/><br/>
    性别：<input type="radio" name="sex" value="1"/>男
         <input type="radio" name="sex" value="0"/>女<br/>
    学历：<select name="edu">
          <option>---请选择---</option>
          <option value="1">高中</option>
          <option value="2">专科</option>
          <option value="3">本科</option>
         </select><br/>
    爱好：<input type="checkbox" name="hobbies" value="1"/>吃
         <input type="checkbox" name="hobbies" value="2"/>玩
         <input type="checkbox" name="hobbies" value="3"/>睡<br/>
    简介：<textarea rows="5" cols="20" name="description"></textarea><br/>
    <input type="submit" value="注册"/>
    </form>

    ${message}<br/>
    <a href="${pageContext.request.contextPath}/">返回</a>
</body>
</html>
